home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
movewipe.zip
/
MOVEWIPE.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1986-10-05
|
21KB
|
1,037 lines
{╔════════════════════════════════════════════════════════════════════════╗
║ MOVE.COM by Lawrence Spiwak 08/19/86 ║
║ ║
╚════════════════════════════════════════════════════════════════════════╝}
program Move_File_Across_Subdirs;
const
BufSize = 20000;
type
String2 = string[2];
String4 = string[4];
String255 = string[255];
RegType = record ax,bx,cx,dx,bp,si,di,ds,es,flags : integer end;
var
NextFile : boolean;
InputFile : string[12];
OutputFile : string[12];
InPath : string[243];
OutPath : string[243];
File1 : string[255];
File2 : string[255];
FileIn : file;
FileOut : file;
Handle1 : integer;
Handle2 : integer;
Attribute : integer;
Names : array[1..600] of string[12];
DataBlock : array [1..BufSize] of byte;
CompBlock : array [1..BufSize] of byte;
ErrorA : byte;
I,J,K : integer;
BlocksRead : integer;
PutUp : string[37];
Address1 : string[37];
Address2 : string[19];
OKToProceed : boolean;
Regs : RegType;
Bytes1 : integer;
Bytes2 : byte;
Bytes3 : integer;
Bytes4 : byte;
Buffer : string[127];
CmdLine : string[127] absolute cseg:$80;
Sort : boolean;
Retry : boolean;
procedure Convert_Cases(var InputString : String255);
var
Temp : char;
A,B : integer;
begin
B:=length(InputString);
for A:=1 to B do begin
Temp:=InputString[A];
InputString[A]:=UpCase(Temp);
end;
end;
procedure Translate;
var
Index : integer;
begin
PutUp:='NNWDXHQD/BPL!azM`xqfmdd!Rqhx`lw0/01';
Address1:='311FVmjufqthux!Amue$03/4';
Address2:='Ndmaptsmf+!EM41:/2';
for Index:=1 to Length(PutUp) do
if Odd(Index) then
PutUp[Index]:=chr(ord(PutUp[Index])-1)
else
PutUp[Index]:=chr(ord(PutUp[Index])+1);
for Index:=1 to Length(Address1) do
if Odd(Index) then
Address1[Index]:=chr(ord(Address1[Index])-1)
else
Address1[Index]:=chr(ord(Address1[Index])+1);
for Index:=1 to Length(Address2) do
if Odd(Index) then
Address2[Index]:=chr(ord(Address2[Index])-1)
else
Address2[Index]:=chr(ord(Address2[Index])+1);
Writeln(PutUp);
Writeln;
end;
function LegalFile(FileName : String255) : Boolean;
var
Legal : boolean;
A : integer;
begin
Legal:=True;
for A:=1 to length(Filename) do
if not(FileName[A] in ['A'..'Z','\','*','?','-','_','$','.',':','1'..'9']) then
Legal:=False;
LegalFile:=Legal;
end;
procedure Get_Command_Line;
var
Temp : char;
TempFile : string[255];
A,B,C : integer;
begin
Buffer:=CmdLine;
{$V-} Convert_Cases(Buffer) {$V+};
A:=1;
while (Buffer[1]=' ') and (A<(Length(Buffer)+1)) do begin
Buffer:=Copy(Buffer,2,Length(Buffer)-1);
A:=A+1;
end;
A:=1; B:=0;
while (A<Length(Buffer)+1) and (B=0) do
if not (Buffer[A] in ['!'..'_']) then
B:=A
else
A:=A+1;
TempFile:=Copy(Buffer,1,B-1);
if Length(TempFile)<1 then begin
Writeln;
Write('Specify: ');
TextColor(White);
Writeln('MOVEWIPE source_file destination_file /S');
TextColor(Yellow);
Writeln;
Writeln('To move multiple files using wildcards, you must specify the destination path');
Writeln('only (or another wildcard). For example:');
Writeln;
Writeln(' MOVEWIPE d1:dir1\dir2\filename.* d2:dir3\dir4\*.*');
Writeln;
Writeln('Files selected with the wildcard cannot be moved to a single file.');
Writeln('Single files cannot be copied to wildcard files. Files selected with');
Writeln('the wildcard cannot be renamed in the copying process. However, single');
Writeln('files may be renamed by simply specifying a different destination name.');
Writeln('If the destination name is not found the current filename will be used.');
Writeln;
Writeln('An optional switch "/S" allows the user to sort the directory by filename.');
Writeln;
Writeln('If you find this program of use, please send $10 in contributions to:');
Writeln;
Writeln(' ',copy(PutUp,17,15));
Writeln(' ',Address1);
Writeln(' ',Address2);
Halt;
end;
C:=Length(Buffer)-B+1;
Buffer:=Copy(Buffer,B,C);
if not (Buffer[1]=' ') then begin
Writeln('Specify a Destination File');
Halt;
end
else
Buffer:=Copy(Buffer,2,Length(Buffer)-1);
if not (LegalFile(TempFile)) then begin
Writeln('Illegal source filename');
Halt;
end;
B:=0;
for A:=length(TempFile) downto 1 do
if (((TempFile[A]='\') or (TempFile[A]=':')) and (B=0)) then
B:=A;
if (B>0) then begin
A:=Length(TempFile);
InputFile:=Copy(TempFile,B+1,(A-B));
InPath:=Copy(TempFile,1,B);
if InputFile='' then begin
Writeln('Specify an Input File');
Halt;
end;
end
else begin
InputFile:=TempFile;
InPath:=''
end;
if (Length(InPath)=2) and (InPath[2]=':') then begin
GetDir(Ord(InPath[1])-64,InPath);
if InPath[Length(InPath)]<>'\' then
InPath:=InPath+'\';
end
else if InPath='' then begin
GetDir(0,InPath);
if InPath[Length(InPath)]<>'\' then
InPath:=InPath+'\';
end;
A:=1;
while (Buffer[1]=' ') and (A<Length(Buffer)) do begin
Buffer:=Copy(Buffer,2,Length(Buffer)-1);
A:=A+1;
end;
A:=1; B:=0;
while (A<128) and (B=0) do
if not (Buffer[A] in ['!'..'_']) then
B:=A
else
A:=A+1;
TempFile:=Copy(Buffer,1,B-1);
Buffer:=Copy(Buffer,B,Length(Buffer)-Length(TempFile));
B:=Length(TempFile);
if not (LegalFile(TempFile)) then begin
Writeln('Illegal destination filename');
Halt;
end;
B:=0;
for A:=length(TempFile) downto 1 do
if (((TempFile[A]='\') or (TempFile[A]=':')) and (B=0)) then B:=A;
if (B>0) then begin
A:=Length(TempFile);
OutputFile:=Copy(TempFile,B+1,(A-B));
OutPath:=Copy(TempFile,1,B);
end
else begin
OutputFile:=TempFile;
OutPath:='';
end;
if (Length(OutPath)=2) and (OutPath[2]=':') then begin
GetDir(Ord(OutPath[1])-64,OutPath);
if OutPath[Length(OutPath)]<>'\' then
OutPath:=OutPath+'\';
end
else if OutPath='' then begin
GetDir(0,OutPath);
if OutPath[Length(OutPath)]<>'\' then
OutPath:=OutPath+'\';
end;
A:=1;
while (Buffer[1]=' ') and (A<(Length(Buffer)+1)) do begin
Buffer:=Copy(Buffer,2,Length(Buffer)-1);
A:=A+1;
end;
end;
procedure Check_Input_File;
var
FileThere : boolean;
Index : integer;
Temp : integer;
begin
with Regs do begin
File1:=InPath+InputFile+chr(0);
Index:=0;
Attribute:=0;
Temp:=1;
while (Attribute<>Temp) and (Index<5) do begin
ax:=$4300; {Get attribute}
ds:=seg(File1);
dx:=ofs(File1)+1;
Intr($21,Regs);
Attribute:=cx;
ax:=$4300; {Get attribute again for safecheck. Check up to 5 times}
ds:=seg(File1);
dx:=ofs(File1)+1;
Intr($21,Regs);
Temp:=cx;
Index:=Index+1;
end;
if Attribute<>Temp then begin
TextColor(LightRed);
Writeln;
Writeln('Error reading attributes : Transient values returned. Program aborted.');
Halt;
end;
ax:=$4301; {Set attribute to null}
cx:=$0000;
ds:=seg(File1);
dx:=ofs(File1)+1;
Intr($21,Regs);
Assign(FileIn,InPath+InputFile);
{$I-} Reset(FileIn) {I$+};
FileThere:=(IOresult=0);
if FileThere then
Close(FileIn);
if not FileThere then begin
Writeln('File ',InPath,InputFile,' not found.');
Halt;
end;
end;
end;
procedure Check_Output_File;
var
Temp : char;
FileThere : boolean;
CheckFile : string[255];
begin
Temp:='Y';
File2:=OutPath+OutputFile+chr(0);
Assign(FileIn,OutP